package com.baizhi.service.impl;

import com.baizhi.dao.UserDao;
import com.baizhi.entity.User;
import com.baizhi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("userService")
public class UserServiceImpl implements UserService {
    private UserDao userDao;
    @Autowired
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }


    @Override
    public int register(User user) {
        int i = userDao.insertUser(user);
        return i;
    }

    @Override
    public User selectByUserName(String username) {
        User user = userDao.selectByUserName(username);
        return user;
    }

    @Override
    public boolean login(String username, String password) {
        boolean result = false;
        User user = userDao.selectByUserName(username);
        if(user!=null && user.getUserPassword().equals(password)){
            result = true;
        }
        return result;
    }
}
